package storebytestream;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.text.DateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Iterator;

import com.mysql.cj.result.BinaryStreamValueFactory;

public class InsertbytesStr {
	
	Connection conn = null;
	Statement stmt = null;
	ResultSet rs = null;
	String username;
	String password;
	int count;
	
	public InsertbytesStr() {
		// TODO Auto-generated constructor stub
	        
	            try {
					conn = DriverManager.getConnection("jdbc:mysql://10.100.20.18/mydatabase?" + "user=fengying&password=123456pw");
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}	                                          	                      	           
	            try {
					System.out.println("conn.isClosed: " +conn.isClosed() );
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
	            try {
					stmt = conn.createStatement();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}		          	          	          
	}
	
		
		
		   		 		    
			
			 
			 		 
							
public void insertbytesStr(String bytesStr ) {
	
	
	 
	 
	    try {		    			    		
			count = stmt.executeUpdate("INSERT INTO load_file (load_file) VALUES("+bytesStr+")");
			
			
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}	
	    if (count==1) {
						    
			   					
			System.out.println("insertbytesStr: " +"sucucess" );
			
		}else {
			if (count==2) {
				System.out.println("insertbytesStr: " +"failed" );
				
			}
			
		}
	   		 		    
		
		 
		 		 
				
}	
}
